package com.khh.aop;

import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Service;

/**
 * Created by webrx on 2017-09-09.
 */
@Service("mylog")//注解aop
@Aspect //注解aop 必不可少
public class Mylog {

    /*包下Teacher类中所有以s开头方法都执行 open()*/
    @Before("execution(public * com.khh.entity..Teacher.s*(..))")
    public void open(){
        System.out.println("数据库打开");
    }

    /*包下所有方法所有类都执行 close（）*/
    @After("execution(public * com.khh.entity..*.*(..))")
    public void close(){
        System.out.println("数据库关闭");

    }
}
